class ChiGoods{
	constructor(){
		this.url = "http://localhost/dist/static/chidata.json";
		this.cont = document.querySelector(".container .childRead .childimg");
		this.load();
	}
	load(){
		ajax({
			url:this.url
		}).then((res)=>{
			this.res = JSON.parse(res);
			this.display();
		});
	}
	display(){
		var strchild = "";
	    strchild = `<div class="childimgbox">
					<a href="#"><img src="http://img1.zazhipu.com/bookpic/201910/2019101610514.png?imageMogr2/thumbnail/450x" /></a>
				</div>`;
	    for(var i=0;i<this.res.length;i++){
	        strchild += `<div class="childimgbox" index="${this.res[i].goodsId}">
	        			<a href="pages/details.html?id=${this.res[i].goodsId}" target="_blank">
						<img src="${this.res[i].img}" alt="" />
						<p>${this.res[i].name}</p>
						<div class="childMoney">
							<div class="left">${this.res[i].price}</div>
							<div class="right">${this.res[i].details}</div>
						</div>
						</a>
					</div>`;
	    }
		this.cont.innerHTML = strchild;
	}
}

new ChiGoods();